<template>
	<view class="u-page">
		<u-list>
			<u-list-item v-for="(item, index) in myFollowLists" :key="item.id">
				<u-cell :title="item.username" @click="goTopage(item.id,item.avatar,item.username)">
					<u-avatar slot="icon" shape="square" size="35" :src="ImgUrl+item.avatar"
						customStyle="margin: -3px 5px -3px 0"></u-avatar>
					<u-icon slot="right-icon" :name="manOrWoman[item.gender]" :color="manOrWomanColor[item.gender]"
						size="28" customStyle="margin: -3px 35px -3px 0"></u-icon>
				</u-cell>
			</u-list-item>
		</u-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				myFollowLists: [],
				ImgUrl: '',
				manOrWoman: ['woman', 'man'],
				manOrWomanColor: ['#ffaaff', '#2979ff'],

			}
		},
		onLoad() {
			this.ImgUrl = getApp().globalData.ImgUrl
		},
		onShow() {
			this.getFollow()
		},
		methods: {
			async getFollow() {
				let BaseUrl = getApp().globalData.BaseUrl
				let token = uni.getStorageSync('token')
				await uni.request({
					url: BaseUrl + '/user/follow',
					method: "GET",
					header: {
						'Content-Type': 'application/json',
						'token': token
					},
					success: (res) => {
						// console.log(res)
						this.myFollowLists = res.data.data
						// let myFollowIds = []
						// res.data.data.forEach(v => {
						// 	myFollowIds.push(v.id)
						// })
						// uni.setStorageSync('myFollowIds',myFollowIds)
					}
				})
			},
			goTopage(userId, originAvatar, username) {
				uni.navigateTo({
					url: '/pages/Personal/Personal?userId=' + userId + '&avatar=' + originAvatar +
						'&username=' + username
				})
			},
		}
	}
</script>

<style>

</style>
